package com.wan.lession.aop;

import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.MethodInterceptor;
import org.graalvm.compiler.phases.common.inlining.walker.MethodInvocation;

import java.util.Arrays;

public class MyMethodIntercepter implements MethodInterceptor, Advice {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        System.out.println("环绕的前置增强");
        //需要进行放行
        //判断方法名 员工工资计算方法
        System.out.println(invocation.getMethod().getName());
        //方法参数 判断参数中的员工名称
        System.out.println(Arrays.toString(invocation.getArguments()));
        //proceed 方法的返回值
        String proceed = (String) invocation.proceed();
        System.out.println("环绕的后置方法");
        //判断带员工是小姨 ,让他工资+1W
        return proceed+" world";
}

    @Override
    public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable {
        return null;
    }
}
